<?php

class allview extends content
{
   var $category_parent;
	var $articles;
	var $items;
	var $videos;
	var $writers;
	function allview()
	{
		mp('loading allview');
	}
	
	
	function digest()
	{
		global $conf;

		
		
		$category=new content_category();
		$category->where['id']=$conf->qm[1];
		$category->get_category();
		mp('got category');

		$this->get_videos($category->piece['id']);

		if($category->piece['type']=='video' && $category->piece['status']=='enabled')
		{
			mp('enabled video');
			$serial=unserialize($category->piece['serial']);
			$conf->style['masthead']=$category->piece['name'];
			$conf->style['background'].='background-image:url('.ap($serial["serial_style_background_image"]).');';
			$conf->style['background'].='background-color:#'.$serial["serial_style_background_color"].';';
			$conf->style['custom-masthead']=='color:#'.$serial["serial_style_masthead_color"].';';
			mp(ap($category->piece['image']));
				
				if(!empty($category->piece['image']))
				{
					$conf->style['masthead']='<img src="'.ap($category->piece['image']).'"/>';
				}
			
		}
		
			$this->display=TRUE;
			$this->category_parent = $category->piece;
			$conf->page_render='assets/pages/allview.php';

	}
	function get_children($cat)
	{
		
		global $conf;
		$category=new content_category();
		unset($category->where);
		$category->where['parent']=$cat;
		$category->where['type']='post';
		$category->get_category();
		$this->writers=$category->data;
	}
	function get_items($aid,$cat)
	{
		mp('grab items');
		$sql = "SELECT a.*,b.image,b.thumb,c.*,d.name FROM content as a, content_image as b, content_post as c,content_category as d WHERE a.id = b.id and a.id = c.id and c.author=$aid and c.author=d.id and a.category=$cat";
		$result = mysql_query($sql); 
		while($row=mysql_fetch_array($result))
		{	

			//print_r($row);
			
			$m[]=$row;
		}
		
		return $m;

	}
	

}
